jQuery(document).ready(function() {
	$.ajax({
		async : false,
		url : projectPath + "user/getCurrentUser.do",
		data : {},
		dataType : "json",
		success : function(data) {
			$('#org').val(data.orgname);
			$('#org').attr('data', data.orgcode);
		}
	});
	initTable();
	App.setPage("complaintSup");  //Set current page
	App.init(); //Initialise plugins and elements
	bindItem("itemtypecode", null, null);
	//列表查询事件
	$('#search').click(function(){
		$('#table').bootstrapTable(('refresh'));  // 很重要的一步，刷新url！
	});
	
	//绑定机构下拉列表
	bindOrg2('org');
	 
});	

function initTable(){
	$('#table').bootstrapTable({
		method: 'post',
	    url: basePath() + 'supervise/complaintList.do',
	    pagination: true, //分页
	    dataType: "json",
        contentType: "application/json",
        pageList: [10, 20, 50, 100],  //可供选择的每页的行数（*）
        striped: true,      //是否显示行间隔色
        sidePagination: "server",
        showHeader:true,
        queryParams:function(params) {
        	var param ={};
        	param.pageNum =  params.offset / params.limit + 1;
        	param.pageSize = params.limit;
        	param.orgCode = $('#org').attr('data');
        	var itemNo = $('#itemtypecode').val();
        	var startTime = $('#startapplytime').val();
        	var endTime = $('#endapplytime').val();
        	if(""!= itemNo)
        		param.itemNo = itemNo;
        	if(""!= startTime)
            	param.startApplyTime = startTime;
        	if(""!= endTime){
        		param.endApplyTime = endTime;
        	}
            return param;
        },
	    columns: [
	    	
	    [{
            field : 'number',  
            title : '序号',  
            align : 'center',
            width : '50px',
            rowspan: 2,
            formatter : function(value, row, index) {  
                var page = $('#table').bootstrapTable("getPage");  
                return page.pageSize * (page.pageNumber - 1) + index + 1;  
            }  
        }, {
	        field: 'itemname',
	        title: '政务项目' ,
	        rowspan: 2
	     
	    }, {
	        field: 'orgname',
	        title: '所属机构' ,
	        rowspan: 2
	     
	    }, {
	        field: 'serviceattitude',
	        title: '服务态度',
	        colspan: 5 
	    }, {
	        field: 'handlespeed',
	        title: '办理速度',
	        colspan: 5 
	    }],[
	    	{
		        field: 'fiveStar',
		        title: '五星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(5,1, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'fourStar',
		        title: '四星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(4,1, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'threeStar',
		        title: '三星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(3,1, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'twoStar',
		        title: '二星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(2,1, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'firstStar',
		        title: '一星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(1,1, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
	    	{
		        field: 'bFiveStar',
		        title: '五星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(5,2, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'bFourStar',
		        title: '四星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(4,2, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'bThreeStar',
		        title: '三星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(3,2, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'bTwoStar',
		        title: '二星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(2,2, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    },
		    {
		        field: 'bfirstStar',
		        title: '一星' ,
		        formatter : function(value, row, index) {  
		        	if(0!=value){
		        		return '<a onclick="showDetail(1,2, \''+ row.itemno +'\')">' + value + '</a>';
		        	}else{
		        		return value;
		        	}
	            }  
		    }
	    ]
	    ] 
	});
}

function showDetail(value,flag,itemno){
	setModalSize();
	$('#ifDetailModal').attr("src", "detail.html?itemno="+itemno+"&param="+value+"&flag="+flag);
	$('#modalDetailTile').html("满意度监督提醒详细");
	$("#modalDetail").modal('show');
}